package com.carreirati.evaluation;

import org.springframework.core.convert.converter.Converter;
import org.springframework.format.FormatterRegistry;
import org.springframework.format.support.FormattingConversionServiceFactoryBean;
import org.springframework.roo.addon.web.mvc.controller.converter.RooConversionService;

import com.carreirati.evaluation.domain.Parameter;
import com.carreirati.evaluation.domain.Project;
import com.carreirati.evaluation.domain.Users;

/**
 * A central place to register application converters and formatters. 
 */
@RooConversionService
public class ApplicationConversionServiceFactoryBean extends FormattingConversionServiceFactoryBean {

	@Override
	protected void installFormatters(FormatterRegistry registry) {
		super.installFormatters(registry);
		// Register application converters and formatters
	}
	 
	public Converter<Project, String> getProjectToStringConverter() {
	        return new org.springframework.core.convert.converter.Converter<com.carreirati.evaluation.domain.Project, java.lang.String>() {
	            public String convert(Project project) {
	                return new StringBuilder().append(project.getName()).toString();
	            }
	        };
	    }
	
	  public Converter<Users, String> getUsersToStringConverter() {
	        return new org.springframework.core.convert.converter.Converter<com.carreirati.evaluation.domain.Users, java.lang.String>() {
	            public String convert(Users users) {
	                return new StringBuilder().append(users.getFirstName()).append(' ').append(users.getSurName()).append(" - ").append(users.getEmail()).toString();
	            }
	        };
	    }
	     
	  public Converter<Parameter, String> getParameterToStringConverter() {
	        return new org.springframework.core.convert.converter.Converter<com.carreirati.evaluation.domain.Parameter, java.lang.String>() {
	            public String convert(Parameter parameter) {
	                return new StringBuilder().append(parameter.getGrupo()).append(" - ").append(parameter.getGrade()).append(" - ").append(parameter.getWeight()).toString();
	            }
	        };
	    }
	    
}
